#include<stdio.h>

int gcd(int num,int num1);

int main()
{
	int num = 0,num1 = 0;
	scanf("%d %d",&num,&num1);
	
	printf("%d",gcd(num,num1));
	return 0;
}

int gcd(int num,int num1)
{
	return num%num1?gcd(num1,num%num1):num1;
}
